package com.kfm.am.exec;

import java.util.Objects;
import java.util.Random;

public class Student {

    private int id;
    private double score;
    private static int i = 1;

    public Student() {
        this.id = i++;
        this.score= new Random().nextDouble(60, 100);
    }

    public String toString() {
        return String.format("Student { 编号：" + id + " , 成绩： %.2f }", score);
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        Student student = (Student) object;
        return id == student.id && Double.compare(score, student.score) == 0;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, score);
    }

    public int getId() {
        return id;
    }

    public double getScore() {
        return score;
    }

    public static int getI() {
        return i;
    }
}
